<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<title>新增邮寄地址</title>
	<meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport" />
	<meta content="yes" name="apple-mobile-web-app-capable" />
	<meta content="black" name="apple-mobile-web-app-status-bar-style" />
	<meta content="telephone=no" name="format-detection" />
	<link href="css/style_2.css" rel="stylesheet" type="text/css" />
</head>
<style>
	a {
		width: inherit;
		height: inherit;
	}

	button {
		background: #fd8238;
		color: #fff;
		font-size: 14px;
		display: block;
		width: 100%;
		height: 40px;
		line-height: 40px;
		text-align: center;
		border-radius: 3px;
		box-shadow: 0 1px 3px #b7b7b7
	}
</style>

<body>

	<section class="aui-flexView">
		<header class="aui-navBar aui-navBar-fixed b-line">
			<a href="javascript:;" class="aui-navBar-item">
				<i class="icon icon-return"></i>
			</a>
			<div class="aui-center">
				<span class="aui-center-title">{{data?'修改地址':'新增邮件地址'}}</span>
			</div>
			<a href="javascript:;" class="aui-navBar-item">
				<i class="icon icon-sys"></i>
			</a>
		</header>
		<section class="aui-scrollView">
			<div class="aui-address-box">
				<form action="">
					<div class="aui-address-cell-item">
						<div class="aui-cell-name">收件人</div>
						<div class="aui-cell-input">
							<input type="text" class="cell-input" placeholder="姓名" autocomplete="off" name="cons"
								value="{{data?data.cons:''}}">
						</div>
					</div>
					<div class="aui-address-cell-item">
						<div class="aui-cell-name">联系手机</div>
						<div class="aui-cell-input">
							<input type="text" class="cell-input" placeholder="收件人电话号码" autocomplete="off"
								name="constel" value="{{data?data.constel:''}}">
						</div>
					</div>
					<div class="aui-address-cell-item">
						<div class="aui-cell-name">所在地区</div>
						<div class="aui-cell-input cell-input-text">
							<input type="text" class="cell-input" readonly id="J_Address" placeholder="北京 北京市"
								name="city" value="{{data?data.city:''}}">
						</div>
					</div>
					<div class="aui-address-cell-item">
						<div class="aui-cell-name">详细地址</div>
						<div class="aui-cell-input">
							<input type="text" class="cell-input" placeholder="发票寄送的详细地址信息" autocomplete="off"
								name="dele" value="{{data?data.dele:''}}">
						</div>
					</div>
					<div class="aui-address-cell-item">
						<div class="aui-cell-name">邮政编号</div>
						<div class="aui-cell-input">
							<input type="text" class="cell-input" placeholder="邮政编码号" autocomplete="off" name="email"
								name="dele" value="{{data?data.email:''}}">
						</div>
					</div>
					<div class="aui-address-btn">
						<button type="submit">确定</button>
					</div>
				</form>

			</div>
		</section>
	</section>
	<script src="js/jquery.min.js"></script>
	<script src="js/city.js"></script>
	<script src="js/address.js"></script>
	<script src="https://cdn.bootcdn.net/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.js"></script>
	<script>
		/**
		 * 默认调用
		 */
		!function () {
			var $target = $('#J_Address');

			$target.citySelect();

			$target.on('click', function (event) {
				event.stopPropagation();
				$target.citySelect('open');
			});

			$target.on('done.ydui.cityselect', function (ret) {
				$(this).val(ret.provance + ' ' + ret.city + ' ' + ret.area);
			});
		}();

		$('form').submit(function (e) {
			e.preventDefault()
			if (location.href.includes('id')) {
				$.cookie('idup', location.href.split('id=')[1])
				$.get('/updata1', $(this).serialize(), data => {
					alert(data)
					if (data == '更新成功') {
						location.href = '/address'
					}
				})
			} else {
				$.get('/conadd', $(this).serialize(), data => {
					alert(data)
					if (data == '保存成功') {
						location.href = '/address'
					}
				})
			}

		})
		$('.aui-navBar-item').click(function () {
			history.back()
		})
	</script>
</body>

</html>